package com.lawyers.util;
import java.security.MessageDigest;

/**
 *
 * @author Ariel
 */
public class MD5
	{
    // Genera el codigo MD5 de la cadena de texto pasada como parametro.
	public static String parse(String cad)
        {
        if(cad == null || cad.length() == 0) return null;

        try{
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update( cad.getBytes() );
            byte[] hash = digest.digest();

            cad = "";
            for(int i=0; i<hash.length; i++)
                {
                cad += Integer.toHexString( (hash[i]<0)? hash[i]+255 : hash[i] );
                }
            }catch(Exception e){ cad = null; }

        return cad;
        }
	
	
	}
